package soft.quicknote.activity;

import android.app.ActionBar;
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

import soft.quicknote.R;
import soft.quicknote.SettingFragment;

public class SettingActivity extends AppCompatActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
    private final static String TAG = SettingActivity.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        SettingFragment sf = new SettingFragment();
        sf.mContext = this;
        setTitle(R.string.app_name);
        setupActionBar();
        getFragmentManager().beginTransaction().
                replace(android.R.id.content, sf)
                .commit();


    }

    /**
     * Set up the {@link android.app.ActionBar}, if the API is available.
     */
    private void setupActionBar() {
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            // Show the Up button in the action bar.
            actionBar.setDisplayHomeAsUpEnabled(true);
        }
    }


    @Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
        Log.d(TAG, key);
        if (key.equals("")) {
//            Preference connectionPref = findPreference(key);
            // Set summary to be the user-description for the selected value
//           connectionPref.setSummary(sharedPreferences.getString(key, ""));
        }

    }
}
